import java.util.*;

abstract class Animal{
    private String name;  //名字
    private int age;   //年龄

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}
interface IAbility{
    void showInfo();  //输出动物信息
    void cry();    //动物发出叫声
}
class Dog extends Animal implements IAbility{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void showInfo() {
        System.out.println("我是一只狗,我的名字是" + this.getName() + ",今年" + this.getAge() + "岁");
    }

    @Override
    public void cry() {
        System.out.println("旺旺");
        System.out.println(this.getName());
        System.out.println(this.getAge());
    }
}
class Cat extends Animal implements IAbility{
    public Cat(String name, int age) {
        super(name, age);
    }

    @Override
    public void showInfo() {
        System.out.println("我是一只猫,我的名字是" + this.getName() + ",今年" + this.getAge() + "岁");
    }

    @Override
    public void cry() {
        System.out.println("喵喵");
        System.out.println(this.getName());
        System.out.println(this.getAge());
    }
}
class Simulator{
    public void playSound(IAbility animal){
        animal.showInfo();
        animal.cry();
    }
}
class Student{
    private String no;
    private String name;

    public Student(String no, String name) {
        super();
        this.no = no;
        this.name = name;
    }
    public Student() {
        super();
    }
    public String getNo() {
        return no;
    }
    public void setNo(String no) {
        this.no = no;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student [no=" + no + ", name=" + name + "]";
    }
}

// 1、导入相关包

//定义员工类
class Employee {

    private String name;
    private int age;

    public Employee() {
        super();
    }

    public Employee(String name, int age) {
        super();
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
class CarDriver {
    private String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public CarDriver() {}
    public String toString() {
        return "CarDriver [name=" + name+"]";
    }
}
class Car implements Cloneable{
    private String name;
    private CarDriver driver;
    private int[] scores;
    public Car() {
    }
    public String getName() {
        return name;
    }
    public CarDriver getDriver() {
        return driver;
    }
    public int[] getScores() {
        return scores;
    }
    public void setName(String name){
        this.name=name;
    }
    public void setDriver(CarDriver dr){
        this.driver=dr;
    }
    public void setScores(int[] s){
        this.scores=s;
    }
    @Override
    public String toString() {
        return "Car [name=" + name + ", driver=" + driver + ", scores=" + Arrays.toString(scores) + "]";
    }

    public Object clone(){
        Car c = null;
        try {
            c = (Car)super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        if(driver!=null) {
            c.driver=new CarDriver();
            if(driver.getName()!=null)
                c.driver.setName(new String(this.driver.getName()));
        }
        if(name!=null)
            c.name=new String(this.name);
        if(scores!=null) {
            c.scores=new int[this.scores.length];
            for(int i=0;i<this.scores.length;i++){
                c.scores[i]=this.scores[i];
            }
        }
        return c;
    }
}
//主函数
public class Main {

    public static void main(String[] args) {
        // 1、创建有序集合对象
        Collection<Employee> c = new ArrayList<>();

        // 创建3个员工元素对象
        for (int i = 0; i < 3; i++) {
            Scanner sc = new Scanner(System.in);
            String employeeName = sc.nextLine();
            int employeeAge = sc.nextInt();

            Employee employee = new Employee(employeeName, employeeAge);
            c.add(employee);
        }



        // 2、创建迭代器遍历集合
        Iterator it = c.iterator();

        //3、遍历
        while (it.hasNext()) {

            //4、集合中对象未知，向下转型
            Employee e =  (Employee) it.next();

            System.out.println(e.getName() + "---" + e.getAge());
        }
    }
}
